- name: kubernetes.snapshot_controller.state
  rules:
    - alert: D8SnapshotControllerTargetDown
      expr: max by (job) (up{job="snapshot-controller"} == 0)
      for: 1m
      labels:
        severity_level: "8"
        tier: cluster
      annotations:
        plk_markup_format: "markdown"
        plk_protocol_version: "1"
        plk_create_group_if_not_exists__d8_snapshot_controller_health: "D8SnapshotControllerHealth,tier=~tier,prometheus=deckhouse,kubernetes=~kubernetes"
        plk_grouped_by__d8_snapshot_controller_health: "D8SnapshotControllerHealth,tier=~tier,prometheus=deckhouse,kubernetes=~kubernetes"
        plk_ignore_labels: "job"
        summary: Prometheus cannot scrape the snapshot-controller metrics.
        description: |
          The recommended course of action:
          1. Check the Pod status: `kubectl -n d8-snapshot-controller get pod -l app=snapshot-controller`
          2. Or check the Pod logs: `kubectl -n d8-snapshot-controller logs -l app=snapshot-controller -c snapshot-controller`

    - alert: D8SnapshotControllerTargetAbsent
      expr: absent(up{job="snapshot-controller"}) == 1
      for: 15m
      labels:
        severity_level: "8"
        tier: cluster
      annotations:
        plk_protocol_version: "1"
        plk_markup_format: "markdown"
        plk_ignore_labels: "job"
        plk_create_group_if_not_exists__d8_snapshot_controller_health: "D8SnapshotControllerHealth,tier=~tier,prometheus=deckhouse,kubernetes=~kubernetes"
        plk_grouped_by__d8_snapshot_controller_health: "D8SnapshotControllerHealth,tier=~tier,prometheus=deckhouse,kubernetes=~kubernetes"
        summary: There is no `snapshot-controller` target in Prometheus.
        description: |
          The recommended course of action:
          1. Check the Pod status: `kubectl -n d8-snapshot-controller get pod -l app=snapshot-controller`
          2. Or check the Pod logs: `kubectl -n d8-snapshot-controller logs -l app=snapshot-controller -c snapshot-controller`

    - alert: D8SnapshotControllerPodIsNotReady
      expr: min by (pod) (kube_pod_status_ready{condition="true", namespace="d8-snapshot-controller", pod=~"snapshot-controller-.*"}) != 1
      for: 10m
      labels:
        severity_level: "8"
        tier: cluster
      annotations:
        plk_protocol_version: "1"
        plk_markup_format: "markdown"
        plk_labels_as_annotations: "pod"
        plk_create_group_if_not_exists__d8_snapshot_controller_health: "D8SnapshotControllerHealth,tier=~tier,prometheus=deckhouse,kubernetes=~kubernetes"
        plk_grouped_by__d8_snapshot_controller_health: "D8SnapshotControllerHealth,tier=~tier,prometheus=deckhouse,kubernetes=~kubernetes"
        summary: The snapshot-controller Pod is NOT Ready.
        description: |
          The recommended course of action:
          1. Retrieve details of the Deployment: `kubectl -n d8-snapshot-controller describe deploy snapshot-controller`
          2. View the status of the Pod and try to figure out why it is not running: `kubectl -n d8-snapshot-controller describe pod -l app=snapshot-controller`

    - alert: D8SnapshotControllerPodIsNotRunning
      expr: absent(kube_pod_status_phase{namespace="d8-snapshot-controller",phase="Running",pod=~"snapshot-controller-.*"})
      for: 2m
      labels:
        severity_level: "8"
        tier: cluster
      annotations:
        plk_protocol_version: "1"
        plk_markup_format: "markdown"
        plk_create_group_if_not_exists__d8_snapshot_controller_health: "D8SnapshotControllerHealth,tier=~tier,prometheus=deckhouse,kubernetes=~kubernetes"
        plk_grouped_by__d8_snapshot_controller_health: "D8SnapshotControllerHealth,tier=~tier,prometheus=deckhouse,kubernetes=~kubernetes"
        summary: The snapshot-controller Pod is NOT Running.
        description: |
          The recommended course of action:
          1. Retrieve details of the Deployment: `kubectl -n d8-snapshot-controller describe deploy snapshot-controller`
          2. View the status of the Pod and try to figure out why it is not running: `kubectl -n d8-snapshot-controller describe pod -l app=snapshot-controller`
